// Problem: 
// Contest: 
// URL: 
// Memory Limit: 
// Time Limit: 
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
int n=10,tmp=0,tdz=0;
int a1,b1,a2,b2;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int ci=0,fi=0;//方向下标
bool zt[160005];
vector<vector<char>> v(n+2,vector<char>(n+2));
void dfs()
{
	if(a1==a2&&b1==b2)
	{
		return;
	}
	tdz=a1+b1*10+a2*100+b2*1000+fi*10000+ci*40000;
	if (zt[tdz])
	{
		tmp=0;
		return;
	}
	zt[tdz]=1;
	if(v[a1+dx[fi]][b1+dy[fi]]=='*'
		||a1+dx[fi]==0||a1+dx[fi]==n+1
		||b1+dy[fi]==0||b1+dy[fi]==n+1)
	{
		fi++;
		if(fi==4)fi=0;
	}
	else
	{
		a1+=dx[fi];
		b1+=dy[fi];
	}
	if(v[a2+dx[ci]][b2+dy[ci]]=='*'
		||a2+dx[ci]==0||a2+dx[ci]==n+1
		||b2+dy[ci]==0||b2+dy[ci]==n+1)
	{
		ci++;
		if(ci==4)ci=0;
	}
	else
	{
		a2+=dx[ci];
		b2+=dy[ci];
	}
	tmp++;
	dfs();
}
signed main()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>v[i][j];
			if(v[i][j]=='F')
			{
				a1=i,b1=j;
			}
			if(v[i][j]=='C')
			{
				a2=i,b2=j;
			}
		}
	}
	dfs();
	cout<<tmp;
	return 0;
}
